package com.ruoyi.common.NoEnglish;

import com.ruoyi.common.utils.StringUtils;
import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
 * 自定义NoEnglish校验注解实现
 *
 * @author ruoyi
 */
public class NoEnglishValidator implements ConstraintValidator<NoEnglish, String>
{

    private final String MYGUIZE = "^[A-Z]*$";

    @Override
    public boolean isValid(String value, ConstraintValidatorContext constraintValidatorContext)
    {
        return !containsHtml(value);
    }

    public boolean containsHtml(String value)
    {
        Pattern pattern = Pattern.compile(MYGUIZE);
        Matcher matcher = pattern.matcher(value);
        return matcher.matches();
    }
}
